package 共享单车;

import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class JavaBean implements WritableComparable<JavaBean> {
    private String startTime;
    private String endTime;
    private int id;
    private String start_loc;
    private String end_loc;
    private String city;
    private double longitude;
    private double latitiude;

    public int compareTo(JavaBean o) {
        return -(o.id - this.id);
    }

    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeUTF(startTime);
        dataOutput.writeUTF(endTime);
        dataOutput.writeInt(id);
        dataOutput.writeUTF(start_loc);
        dataOutput.writeUTF(end_loc);
        dataOutput.writeUTF(city);
        dataOutput.writeDouble(longitude);
        dataOutput.writeDouble(latitiude);
    }

    public void readFields(DataInput dataInput) throws IOException {
        startTime = dataInput.readUTF();
        endTime = dataInput.readUTF();
        id = dataInput.readInt();
        start_loc = dataInput.readUTF();
        end_loc = dataInput.readUTF();
        city = dataInput.readUTF();
        longitude = dataInput.readDouble();
        latitiude = dataInput.readDouble();
    }

    public void set(String startTime, String endTime, int id, String start_loc, String end_loc, String city, double longitude, double latitiude) {
        this.startTime = startTime;
        this.endTime = endTime;
        this.id = id;
        this.start_loc = start_loc;
        this.end_loc = end_loc;
        this.city = city;
        this.longitude = longitude;
        this.latitiude = latitiude;
    }

    @Override
    public String toString() {
        return startTime + '\t' +
                endTime + '\t' +
                id + "\t" +
                start_loc + '\t' +
                end_loc + '\t' +
                city + '\t' +
                longitude + "\t" +
                latitiude;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getStart_loc() {
        return start_loc;
    }

    public void setStart_loc(String start_loc) {
        this.start_loc = start_loc;
    }

    public String getEnd_loc() {
        return end_loc;
    }

    public void setEnd_loc(String end_loc) {
        this.end_loc = end_loc;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public double getLongitude() {
        return longitude;
    }

    public void setLongitude(double longitude) {
        this.longitude = longitude;
    }

    public double getLatitiude() {
        return latitiude;
    }

    public void setLatitiude(double latitiude) {
        this.latitiude = latitiude;
    }
}
